/*
 * Kelas dana umum merupakan gabungan antara dana umum dan kesempatan
 *
 */

package model.board;

import java.util.*;
import javax.swing.JOptionPane;
import model.Game;

public class DanaUmum
{
    private int jum = 1;
    ArrayList <Dana> arrDana = new ArrayList <Dana>();  //array dimulai dari
    ArrayList <Kes> arrKes = new ArrayList <Kes>();
    public Dana[] arr = new Dana[jum+1];


    public DanaUmum()
    {
        
    }

    public void AssignDana ()
    {
        arrDana.add(0, new Dana("You've got a Rp1000 commission for helping a company!"));
        arrDana.add(1, new Dana("Wow! You've just won a lottery! 10000 Cash for you! Yay!"));
        arrDana.add(2, new Dana("You must pay 5000 fine for drunking."));
        arrDana.add(3, new Dana("Did you forgot to pay government taxes? 10% from your cash now!"));
        arrDana.add(4, new Dana("You've been in a car accident. Pay 3000 for hospital fee."));
    }

    public void AssignKes ()
    {
        
        arrKes.add(0, this.new Kes("Move Forward to Start!"));
        arrKes.add(1, this.new Kes("Full hunger and fun!"));
        arrKes.add(2, this.new Kes("Enjoy Dufan!"));
        arrKes.add(3, this.new Kes("You've been arrested for vandalism! Go to jail!"));
        arrKes.add(4, this.new Kes("You've got a chance to roll the dice again!"));
    }

    public void getMethodKes(int no, Game G)
    {
        JOptionPane.showMessageDialog(null, arrKes.get(no).getNama(), "Chance", 1);
        arrKes.get(no).getMethod(no, G);
    }

    public void getMethodDana(int no, Game G)
    {
        JOptionPane.showMessageDialog(null, arrDana.get(no).getNama(), "Community Chest", 1);
        arrDana.get(no).getMethod(no, G);
    }

    class Dana
    {
        private int no;
        private String nama;

        public Dana(String _nama)
        {
           nama = _nama;
        }
        public int getNo()
        {
            return no;
        }

        public String getNama()
        {
            return nama;
        }

        public void getMethod(int _no, Game G)
        {
            switch (_no)
            {
                case 0:
                    G.current_plyr().addUang(1000);
                    break;
                case 1:
                    G.current_plyr().addUang(10000);
                    break;
                case 2:
                    G.current_plyr().bayar(5000);
                    break;
                case 3:
                    int denda = (int) 0.1*G.current_plyr().getUang();
                    G.current_plyr().bayar(denda);
                    break;
                case 4:
                    G.current_plyr().bayar(3000);
                    break;
            }

        }
    }
    
    class Kes //kesempatan
    {
        private String nama;

        public Kes(String _nama)
        {
            nama = _nama;
        }
        
        public String getNama()
        {
            return nama;
        }

        public void getMethod(int _no, Game G)
        {
            switch (_no)
            {
                case 0:
                    G.current_plyr().setPosisi(1);
                    break;
                case 1:
                    G.current_plyr().setFun(20);
                    G.current_plyr().setHunger(20);
                    break;
                case 2:
                    G.current_plyr().setPosisi(32);
                    break;
                case 3:
                    G.current_plyr().setPosisi(25);
                    break;
                case 4:
                    G.current_plyr().boleh_acak = true;
                    break;
            }
        }
    }
}
